#
# Franklin and Hopper
# need to 
#>module unload PrgEnv-pgi
#>module load PrgEnv-gnu
CC = g++
MPCC = mpicxx #-lmpich_threadm
OPENMP = -fopenmp	
CFLAGS = -O3  #-pg -g -DDEBUG
#CFLAGS = -g -lm
LIBS = -lm -O3 #-pg
ifeq ($(PE_ENV),PGI)
 OPENMP = -mp	
 CFLAGS+= #-fastsse
endif

ifneq ($(TAUROOTDIR),)
	include  $(TAUROOTDIR)/include/Makefile
	CFLAGS+=$(TAU_INCLUDE) $(TAU_DEFS) -DTAU
#	LIBS+=$(TAU_MPI_LIBS) $(TAU_LIBS) 
	LIBS+= $(TAU_LIBS) 
endif

#
# Bassi  - Being retired soon/ Don't have access
#
#CC = cc -+ -qsuppress=1500-036
#MPCC = mpcc
#OPENMP = -qsmp=omp
#CFLAGS = -O3
#LIBS = -lm

#
# Jacquard
#
#CC = pathCC
#MPCC = mpicxx 
#OPENMP = -mp
#LIBS = -lm
#CFLAGS = -O3

#
# DaVinci - Being retired soon/ Don't have access
#
#CC = g++
#MPCC = g++
#OPENMP = -fopenmp
#LIBS = -lm
#CFLAGS = -O3
#MPILIBS = -lmpi++ -lmpi

TARGETS = es-bvs-bl-hybrid es-bvs-bl-mpi es-bvs-bl-serial es-bvs-bl-openmp  serial pthreads openmp mpi

all:	$(TARGETS)

ampi: es-bvs-bl-ampi

report: report.tex
	pdflatex report.tex
	pdflatex report.tex

es-bvs-bl-serial: es-bvs-bl-serial.o es-bvs-bl-common.o
	$(CC) -o $@ $(LIBS) es-bvs-bl-serial.o es-bvs-bl-common.o
es-bvs-bl-serial.o: es-bvs-bl-serial.cpp es-bvs-bl-common.h
	$(CC) -c $(CFLAGS) es-bvs-bl-serial.cpp
es-bvs-bl-openmp: es-bvs-bl-openmp.o es-bvs-bl-common.o
	$(CC) -o $@ $(OPENMP) $(LIBS) es-bvs-bl-openmp.o es-bvs-bl-common.o
es-bvs-bl-openmp.o: es-bvs-bl-openmp.cpp es-bvs-bl-common.h
	$(CC) -c $(OPENMP) $(CFLAGS) es-bvs-bl-openmp.cpp
es-bvs-bl-common.o: es-bvs-bl-common.cpp es-bvs-bl-common.h
	$(CC) -c $(CFLAGS) es-bvs-bl-common.cpp
es-bvs-bl-mpi.o: es-bvs-bl-mpi.cpp es-bvs-bl-common.h
	$(MPCC) -c $(CFLAGS) es-bvs-bl-mpi.cpp
es-bvs-bl-hybrid.o: es-bvs-bl-hybrid.cpp es-bvs-bl-common.h
	$(MPCC) -c $(OPENMP) $(CFLAGS) es-bvs-bl-hybrid.cpp
es-bvs-bl-ampi: es-bvs-bl-ampi.o es-bvs-bl-common.o
	$(CHARMC) -o $@ $(LIBS) $(MPILIBS) es-bvs-bl-ampi.o es-bvs-bl-common.o
es-bvs-bl-ampi.o: es-bvs-bl-mpi.cpp es-bvs-bl-common.h
	$(CHARMC) -c $(CFLAGS) es-bvs-bl-mpi.cpp -o es-bvs-bl-ampi.o


serial: serial.o common.o
	$(CC) -o $@ $(LIBS) serial.o common.o
pthreads: pthreads.o common.o
	$(CC) -o $@ $(LIBS) -lpthread pthreads.o common.o
openmp: openmp.o common.o
	$(CC) -o $@ $(LIBS) $(OPENMP) openmp.o common.o
mpi: mpi.o common.o
	$(MPCC) -o $@ $(LIBS) $(MPILIBS) mpi.o common.o
es-bvs-bl-mpi: es-bvs-bl-mpi.o es-bvs-bl-common.o
	$(MPCC) -o $@  es-bvs-bl-mpi.o es-bvs-bl-common.o $(LIBS)
es-bvs-bl-hybrid: es-bvs-bl-hybrid.o es-bvs-bl-common.o
	$(MPCC) -o $@  es-bvs-bl-hybrid.o es-bvs-bl-common.o $(LIBS) $(OPENMP)

openmp.o: openmp.cpp common.h
	$(CC) -c $(OPENMP) $(CFLAGS) openmp.cpp
serial.o: serial.cpp common.h
	$(CC) -c $(CFLAGS) serial.cpp
pthreads.o: pthreads.cpp common.h
	$(CC) -c $(CFLAGS) pthreads.cpp
mpi.o: mpi.cpp common.h
	$(MPCC) -c $(CFLAGS) mpi.cpp
common.o: common.cpp common.h
	$(CC) -c $(CFLAGS) common.cpp

clean:
	rm -f *.o $(TARGETS)
